<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head th:include="include/head">

</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">


    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>目录管理</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">首页</a></li>
                            <li class="breadcrumb-item active">目录管理</li>
                        </ol>
                    </div>
                </div>
            </div>
            <!-- /.container-fluid -->
        </section>
        <section class="content">
            <div class="card card-info">
                <div class="card-header">
                    <h3 class="card-title">用户信息增加或修改</h3>
                </div>
                <!-- /.card-header -->
                <!--                 form start-->
                <form class="form-horizontal" id="form" method="post"
                      th:action="@{/user/TbUserSave}">

                    <!--                    Integer userId, String userName,Byte userGender-->

                    <input type="hidden" name="userId" th:value="${tbUser.userId}" />
                    <!--                    <input type="hidden" name="pId" th:value="${bean.pid}" />-->
                    <div class="card-body">
                        <div class="form-group row">
                            <label for="userName" class="col-sm-2 col-form-label">用户名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="userName" id="userName" placeholder="用户名称" aria-required="true"
                                       th:value="${tbUser.userName}">
                                <label class="help-block m-b-none" for="userName" id="name-error"><i class="far fa-bell"></i>必填项</label>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="userGender" class="col-sm-2 col-form-label">用户性别</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="userGender"
                                       id="userGender" placeholder="1代表男、2代表女" aria-required="true"
                                       th:value="${tbUser.userGender}">
                                <label class="help-block m-b-none" for="userGender" id="descritpion-error"><i class="far fa-bell"></i>必填项</label>
                            </div>
                        </div>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <button type="submit" class="btn btn-info">保存</button>
                        <!--                        <button type="button" class="btn btn-default float-right" th:attr="data-pid=|${bean.pid}"-->
                        <!--                                id="back">取消</button>-->
                    </div>
                    <!-- /.card-footer -->
                </form>
            </div>
        </section>

    </div>
</div>
<!-- ./wrapper -->
<div th:include="include/foot"></div>
<script>
    $.validator.setDefaults({
        highlight : function(a) {
            $(a).removeClass("is-valid").addClass(
                "is-invalid");
        },
        success : function(a) {
            $(a).prev().removeClass("is-invalid").addClass(
                "is-valid");
            $(a).html('<i class="fas fa-check"></i>验证成功');
        },
        errorClass:"help-block m-b-none",
//        validClass:"help-block m-b-none",
        errorPlacement:function(a,b){
            if(b.is(":radio")||b.is(":checkbox")){
                a.appendTo(b.parent().parent().parent())
            }else{
                a.appendTo(b.parent())
            }},
        submitHandler:function(form){loadPage();form.submit();}
    });
    $().ready(function() {
        $("#back").click(function() {
            loadPage();
            let pId=$(this).data('userId');
            console.log(userId);
            location.href = 'TbUserList?userId='+userId;
        });
        $("#form").validate({
            rules : {
                name : "required",
                descritpion : "required",
                url:"required",
                isShow:{
                    required:true,
                    minlength:1
                }
            },
            messages : {
                name : '<i class="far fa-times-circle"></i>请输入目录名称',
                descritpion : '<i class="far fa-times-circle"></i>请输入目录描述',
                url :'<i class="far fa-times-circle"></i>请输入目录链接',
                isShow:'<i class="far fa-times-circle"></i>请选择是否显示'
            }
        });
    });
    loadPage=function(){
        window.parent.loadPage();
    }
</script>
</body>
</html>